home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir43 / med300.zip / MEPACK.CLA < prev    next >
Text File  |  1994-02-22  |  5KB  |  89 lines

  1.  
  2. !▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  3. !█                                                                       █
  4. !█ MEPACK.CLA                                                            █
  5. !█ Memo field packing/unpacking functions                                █
  6. !█                                                                       █
  7. !█ Revision Number: 1                                                    █
  8. !█ Revision Date  : 22-Feb-94                                            █
  9. !█                                                                       █
  10. !█ Revision History                                                      █
  11. !█   1 Created                                                           █
  12. !█                                                                       █
  13. !▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  14.  
  15.              MEMBER('MEMOEDIT')
  16.  
  17. !─────────────────────────────────────────────────────────────────────────
  18. !                           Local Module Data
  19. !─────────────────────────────────────────────────────────────────────────
  20. qTable       QUEUE,PRE(QUE)                      ! Temp. table for
  21. sLine          STRING(255)                       ! ME_Unpack()
  22.              .
  23.  
  24. !════════════════════════════════════════════════════════════════════════
  25. !      Convert current document from Clarion format to packed format
  26. !════════════════════════════════════════════════════════════════════════
  27. ME_Pack      PROCEDURE( aMemo, bbKeepFormat )
  28.  
  29.              ! Locals:
  30. usLineNo     SHORT                               ! Line index
  31. usMaxLines   SHORT                               ! Max. lines
  32. usDestNdx    SHORT                               ! Dest. index
  33. usLength     SHORT                               ! Line length
  34.  
  35.   CODE
  36.   LOOP usMaxLines = MAXIMUM(aMemo, 1) TO 1 BY -1 ! Loop backwards thru memo
  37.     IF aMemo[usMaxLines] THEN BREAK.             !   Break if not blank
  38.   .                                              ! End loop
  39.   LOOP usLineNo = 1 TO usMaxLines                ! Loop for each memo line
  40.     QUE:sLine = aMemo[usLineNo]                  !   Add to table
  41.     ADD(qTable)                                  !
  42.   .                                              ! End loop
  43.   CMemSet(MED:ulEditBuffer, 20H, MED:usMaxChars) ! Fill memo buffer w/spaces
  44.   usDestNdx = 0                                  ! Set destination index
  45.   LOOP usLineNo = 1 TO usMaxLines                ! Loop for each memo line
  46.     GET(qTable, usLineNo)                        !   Get saved line
  47.     usLength = LEN(CLIP(QUE:sLine))              !   Calc line length
  48.     IF VAL(SUB(QUE:sLine, usLength, 1)) <> eHRt  !   If last char not HRt
  49.       IF NOT OMITTED(2) AND bbKeepFormat         !     If retaining format
  50.         QUE:sLine = CLIP(QUE:sLine) & CHR(eHRt)  !       Append HRt
  51.       .                                          !     Endif
  52.       usLength += 1                              !     For space or HRt
  53.     .                                            !   Endif
  54.     CMemMove(MED:ulEditBuffer+usDestNdx, ADDRESS(QUE:sLine), usLength)
  55.     usDestNdx += usLength                        !   Update dest. index
  56.   .                                              ! End loop
  57.   ME_ReformDoc()                                 ! Reformat document
  58.   FREE(qTable)                                   ! Free table
  59.   RETURN                                         !
  60.  
  61.  
  62. !════════════════════════════════════════════════════════════════════════
  63. !     Convert current document from packed format to Clarion format
  64. !════════════════════════════════════════════════════════════════════════
  65. ME_Unpack    PROCEDURE( aMemo, usWidth )
  66.  
  67.              ! Locals:
  68. usLineNo     USHORT                              ! Line number
  69. usLineStart  USHORT                              ! Line start
  70. usLineEnd    USHORT                              ! Line end
  71.  
  72.   CODE
  73.   MED:usLineWidth = usWidth                      ! Reformat to required width
  74.   ME_ReformDoc()                                 !
  75.   LOOP usLineNo = 1 TO RECORDS( qLine )          ! Loop for each line
  76.     usLineStart = ME_LineStart( usLineNo )       !   Retrive line
  77.     usLineEnd   = ME_LineEnd( usLineNo )         !
  78.     ME_GetBlock(QUE:sLine, usLineStart, (usLineEnd-usLineStart)+1)
  79.     ADD(qTable)                                  !   Add to temp. table
  80.   .                                              ! End loop
  81.   CLEAR( aMemo )                                 ! Clear memo array
  82.   LOOP usLineNo = 1 TO RECORDS( qLine )          ! Loop for each line
  83.     GET(qTable, usLineNo)                        !   Get saved line
  84.     aMemo[usLineNo] = QUE:sLine                  !   Assign to memo array
  85.   .                                              ! End loop
  86.   FREE(qTable)                                   ! Free table
  87.   RETURN                                         !
  88.  
  89.